package cn.springboot.pioneermall.api.chat;

import cn.springboot.pioneermall.core.controller.BaseController;
import cn.springboot.pioneermall.robotChat.domain.HsChatAskAnswerTemplate;
import cn.springboot.pioneermall.robotChat.domain.HsChatMessage;
import cn.springboot.pioneermall.robotChat.service.IHsChatAskAnswerTemplateService;
import cn.springboot.pioneermall.util.Result;
import cn.springboot.pioneermall.util.ResultGenerator;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RequestMapping("/api/v1")
@RestController
public class UserChatController extends BaseController {
    @Resource
    private IHsChatAskAnswerTemplateService hsChatAskAnswerTemplateService;

    @PostMapping("/robotChat/reply")
    public Result getAskTemplateAnswer(@RequestBody HsChatMessage hsChatMessage) {
        String sendContent = hsChatMessage.getSendContent();
        HsChatAskAnswerTemplate hsChatAskAnswerTemplate = new HsChatAskAnswerTemplate();
        hsChatAskAnswerTemplate.setAsk(sendContent);
        HsChatMessage askAnswer = hsChatAskAnswerTemplateService.getAskAnswer(hsChatAskAnswerTemplate
        ,hsChatMessage.getFromId(),hsChatMessage.getFromUserName());
        return ResultGenerator.genSuccessResult(askAnswer);
    }

}
